<?php

/**
 * 
 */
class ProyectosdcGestionAmbientalController extends Sgit_Controller_Action
{

    protected $_main_model = 'ProyectosDCPost';

    public function indexAction()
    {


        $this->_element->ProyetosDCSubCategorias = new Sgit_Form_Element_Select_ProyetosDCSubCategorias('id_sub_cat',null,array(20,21));

        $filtros = new Sgit_Form_Filtros();



        $filtros->addFormSelect(new Sgit_Form_Element_Select_ProyectosDC('id_proyecto', array('label' => 'Proyectos Gestión Ambiental'), array('gma=?' => 1)));
        $filtros->addFormSelect(new Sgit_Form_Element_Select_Datacenter('id_zona'));
        $filtros->addFormSelect($this->_element->ProyetosDCSubCategorias);

        $values = $this->_getFiltrosValues($filtros);
        $filtros->myRender();


        $rows = $this->_model->default->getBySubCat(array(20,21),$values);
        $this->view->rows = $this->_prepareRowsToTr($rows);


 
    }


    protected function _prepareValuesToTr($row)
    {

        $f_fin = ($row['f_repla']) ? $row['f_repla'] : $row['f_entrega'];
        $f_fin = ($row['f_final']) ? $row['f_final'] : $f_fin;


        $row['sub_cat'] = $this->_element->ProyetosDCSubCategorias->getMultiOption($row['id_sub_cat']);

        $row['fecha'] = Sgit_Filter_DateTo::filter($row['fecha']);
        $row['f_fin'] = Sgit_Filter_DateTo::filter($f_fin);
        $row['f_inicio'] = Sgit_Filter_DateTo::filter($row['f_inicio']);

        return $row;
    }


}
